#include "logging.h"

#include "file.hpp"

void Logging_Init(char *appName, const char *saveDir) {
    hhfox::createDirIfNoExist(saveDir);
    FLAGS_stop_logging_if_full_disk = true;
    FLAGS_max_log_size = 50;
    FLAGS_logbufsecs = 0;
    FLAGS_alsologtostderr = true;
    FLAGS_log_dir = saveDir;
    google::InitGoogleLogging(appName);
    google::EnableLogCleaner(2);
    google::InstallFailureSignalHandler();
    google::InstallFailureWriter([](const char *data, unsigned long size) { LOG(ERROR) << data; });
}

void Logging_Uninit() {
    google::DisableLogCleaner();
    google::ShutdownGoogleLogging();
}